Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: race condition #1427

Merged
merged 2 commits into from
Aug 4, 2023
Merged

fix: race condition #1427

merged 2 commits into from
Aug 4, 2023

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Aug 4, 2023

Fixes ugly race condition spotted by brilliant @spalladino

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@benesjan benesjan requested a review from spalladino August 4, 2023 13:33
@@ -138,6 +138,11 @@ export class Synchroniser {

protected async workNoteProcessorCatchUp(limit = 1, retryInterval = 1000): Promise<void> {
const noteProcessor = this.noteProcessorsToCatchUp[0];
if (this.synchedToBlock === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to make this more general i.e.

      if (noteProcessor.status.syncedToBlock === this.synchedToBlock) {
        // Note processor already synched, nothing to do
        this.noteProcessorsToCatchUp.shift();
        this.noteProcessors.push(noteProcessor);
        return;
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in cd3b19d. Thanks

@benesjan benesjan enabled auto-merge (squash) August 4, 2023 14:06
@benesjan benesjan merged commit cd78ec9 into master Aug 4, 2023
@benesjan benesjan deleted the janb/processor-race-condition-fix branch August 4, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants